package com.main.hotel.controller;

import com.main.hotel.entity.RoomType;
import com.main.hotel.service.RoomTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;

import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;

@Controller
public class RoomTypeController {
    @Autowired
    private RoomTypeService roomTypeService;
    @RequestMapping(value = "roomtype/findall",method = RequestMethod.GET)
    @ResponseBody
    public Page<RoomType> findAllRoomType(Integer page, HttpServletResponse response){
     response.setHeader("Access-Control-Allow-Origin","*");
     if(page==null||page<=0){
         page=0;
     }else{
         page-=1;
     }
     return roomTypeService.findAll(page,3);
    }

}
